home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9938 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: news.midusa.net!wpmills
  2. From: wpmills@midusa.net (W. Paul Mills)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: goto
  5. Date: 14 Mar 96 16:17:33 GMT
  6. Organization: Netspace
  7. Message-ID: <wpmills.826820253@wpmills>
  8. References: <Pine.OSF.3.91.960313102715.10701D-100000@io.UWinnipeg.ca>
  9. NNTP-Posting-Host: node2.topeka.midusa.net
  10.  
  11. Bill Simpson <wsimpson@uwinnipeg.ca> writes:
  12.  
  13. >There was a goto thread lately, and my problem is to state this algorithm 
  14. >cleanly without gotos (which I think is easy, but my attempts have been 
  15. >failures).
  16.  
  17. >0. x=0;
  18. >1. x+=erand(maxmean);
  19. >2. if (urand2()>rate(x)/maxrate)
  20. >    goto step 1
  21. >3. if (x<=XMAX)
  22. >    {
  23. >    setdot(x,y,z);
  24. >    goto step 1
  25. >    }
  26. >explanation:
  27. >erand(mean) returns exponential double random number with given mean
  28. >urand2() returns uniform double random number between 0 & 1
  29. >rate(). well the rate of the Poisson process varies with x
  30.  
  31. x = 0
  32.  
  33. do {
  34.     x += erand(maxmean);
  35.     if (urand2() > rate(x) / maxrate) continue;
  36.     setdot(x, y, z);
  37.    } while ( x < XMAX);
  38. --
  39.  ------------------------------------------------------------------- 
  40. : W. Paul Mills          : Compiler Bug: Any action of the compiler :
  41. : Topeka, Kansas, U.S.A. :               that I did not intend. It  :
  42. : wpmills@midusa.net     :               couldn't be my code?       :
  43. : wpmills@tyrell.net     : ---------------------------------------- :
  44. : paulmills@bix.com      : Linux:        The Operating system of a  :
  45. : paulmills@aol.com      :               GNU Generation.            :
  46. : PAULMILLS@delphi.com   : ---------------------------------------- :
  47. : compuserve 70023,1750  : #define MY_TRUE_LOVE computer            :
  48.  ------------------------------------------------------------------- 
  49.